<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ajax_model
 *
 * @author hassanali
 */
class ajax_model extends cms_model {
    //put your code here
    public function __construct() {
        parent::__construct();
    }
    
    public function get_message_replay($limit,$start,$id,$order ='desc'){
        
        $this->db->limit($limit,$start);
        $this->db->order_by('private_message_replies.id',$order);
        $this->db->select('users.username');
        $this->db->select('private_message_replies.*');
        $this->db->join('users','users.id = private_message_replies.user_id');
        //$replay=$this->db->get_where('private_message_replies',array('message_id'=>$id));
        $sql=$this->db->get_where('private_message_replies',array('message_id'=>$id));
        
        return $sql->result();
    }

    
    public function get_message($limit,$start,$id,$order ='desc'){
        
        $this->db->limit($limit,$start);
        $this->db->order_by('private_messages.id',$order);
        $this->db->select('users.username');
        $this->db->select('private_messages.*');
        $this->db->join('users','users.id = private_messages.sender_id');
        //$replay=$this->db->get_where('private_message_replies',array('message_id'=>$id));
        $sql=$this->db->get_where('private_messages',array('reciver_id'=>$id));
        
        return $sql->result();
    }
    
    }

?>
